package com.example.smarterhouse;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;

public class AlertPopup extends Activity {

	Controller controll;
	Context con;
	Class<?> lastLocation;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_alert_popup);
		controll = Controller.getInstance();
		lastLocation =controll.getCurrrentClass();
		con = getApplicationContext();
		
		Intent intent = new Intent();
		String push = intent.getExtras().getString("push");
		dialog();
	}

	private void dialog(){
		Log.d("IN ", "DIALOG");
		new AlertDialog.Builder(this)
		.setTitle("Titel")
		.setMessage("Do you really want to whatever?")
//		.setIcon(android.R.drawable.ic_dialog_alert)
		.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
			
		    public void onClick(DialogInterface dialog, int whichButton) {
//		        Toast.makeText(con, "Yaay", Toast.LENGTH_SHORT).show();
		    	controll.setClassDest(Functions.class);
		    	controll.setCon(con);
		    	String alert = "getDevice_"+"insert string here";
		    	controll.callAsync(alert);
		    }})
		 .setNegativeButton("No", new DialogInterface.OnClickListener() {
			
			
			public void onClick(DialogInterface dialog, int which) {
				if (lastLocation == Functions.class) {
					controll.setClassDest(lastLocation);
			    	controll.setCon(con);
			    	String alert = controll.getRollBack();
			    	controll.callAsync(alert);
				} else if(lastLocation == RoomAndDeviceList.class){
					
				}
				
				
			}
		}).show();
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// TODO Auto-generated method stub
		return super.onCreateOptionsMenu(menu);
	}
	

	
	
}
